<?php


namespace App\logic;


use App\Models\Orders;
use App\servers\RabbitmqServer;
use App\servers\RlySmsServer;

class CsendsmsLogic
{
    /**
     * @var 获取剩余半小时复诊用户信息
     * @return array|bool
     */
    public static function visitUserInfo()
    {
        $where = ['status' => '0'];
        $orderData = Orders::getOrderIndex($where);//获取完成支付订单
        if(!$orderData) return false;
        $arr = self::filter($orderData);//获取剩余30分钟未发送复诊信息
        $uers = self::getUserInfo($arr);//获取用户信息
        return $uers;
    }

    public static function filter($data)
    {
        static $arr = [];
        foreach ($data as $key => $value){
            if($value->visit->status == 0){;
                $arr[] = $value->visit;
            }
        }
        return self::getTime($arr);
    }

    /**
     *获取用户的信息
     */
    public static function getUserInfo($data)
    {
        static $arr = [];
        foreach ($data as $key => $value){
            $arr[] = $value->user;
        }
        return $arr;
    }

    public static function getTime($data)
    {
         static $arr = [];
        foreach ($data as $key => $value){
            $nowTime = time();
            if($nowTime - $value['datetime'] <= 30*60){
                $arr[] = $value;
            }
        }
        return $arr;
    }
}
